const Controller = require("egg").Controller;

class ChapterController extends Controller{
    // 查找章节
    async getChapterDetail(){
        let id = this.ctx.params.id;
        const chapter = await this.ctx.service.chapter.getChapterDetail(id);
        await this.ctx.render("/pc/book_detail.html",{
            chapter
        })
    }
    // 添加章节
    async create(){
        let id = this.ctx.request.body.id;
        let chapter = this.ctx.request.body.chapter;
        const chapterList = await this.ctx.service.chapter.postChapterDetail(id,chapter);
        await this.ctx.render("/pc/book_detail.html",{
            chapterList
        })
    }
}
module.exports = ChapterController